home *** CD-ROM | disk | FTP | other *** search
- // GenericSerial.h
- // constants, message formats, etc... used on Palm & Mac
-
-
- // opcode definitions
- enum
- {
- kDirEnumerate = 0, // whats in a directory?
- kFileCreate, // create a file...
- kDirCreate,
- kFileOpen, // Open a file
- kFileClose, // close a file
- kFileRead, // read bytes from a file
- kFileWrite, // write bytes from a file
- kFileSeek, // move file marker
- kFileSize, // how big is the file?
- kFileResize, // set file size
- kFileRename, // rename a file(!)
- kFileDelete, // delete a file
-
- kFileOpResult // result code from a request.
- };
-
- #define kMaxExtraDataSize 512
-
- #define kCookieValue 'hack'
-
- /*
- Message packet format.
-
- All messages consist of a packet of this format,
- optionally followed by a variable length data buffer.
- Note: this structure aligns the same way on PPC (Mac) & 68k (Palm).
- All requests are initiated by the "client".
- For every message the client sends the server, it will receive a message in response.
- Read/write messages are limited to kMaxExtraDataSize bytes at a time,
- so large read/writes will be broken up into multiple messages.
- */
- typedef struct
- {
- unsigned long cookie;
-
- unsigned short op;
- unsigned short dataSize; // Amount of extra data present after this structure.
- unsigned short result;
- unsigned short reserved;
-
- long param1;
- long param2;
- long param3;
- long param4;
- } MyPacket;
-
-
- // prototypes:
- // Facilities provided by GenericSerial.c:
-
- short RemoteFileRead(long filep, long numBytes, long *numBytesRead, char *bufP, char dataStoreBased, long offset);
- short RemoteFileWrite(long filep, long numBytes, long *numWritten, char *bufP);
-
- short RemoteDirCreate(char *path);
- short RemoteFileCreate(char *path);
- short RemoteFileDelete(char *path);
- short RemoteFileOpen(char *path, long perm, long *filePP);
- short RemoteFileClose(long filep);
-
- short RemoteFileSeek(long filep, short origin, unsigned short offset);
- short RemoteFileSize(long filep, long *size);
- short RemoteFileResize(long filep, long newsize);
-
- short RemoteDirIterate(long dirP, long *iteratorP, char *buf, long *size, long *attr);
-
- void ServeSomething(void);
-
-
- // Functions required by GenericSerial.c:
- short SerialRead(short numBytes, char *bufP);
- short SerialWrite(short numBytes, char *bufP);
-
-
- short LocalDirIterate(long dirP, unsigned long *iteratorP, char *buf, long *size, long *attr);
-
- short LocalFileCreate(char *path);
- short LocalFileDelete(char *path);
- short LocalDirCreate(char *path);
-
- short LocalFileOpen(char *path, long perm, long *filePP);
- short LocalFileClose(long filep);
-
- short LocalFileRead(long filep, long numBytes, long *numBytesRead, char *bufP);
- short LocalFileWrite(long filep, long numBytes, long *numWritten, char *bufP);
-
- short LocalFileSeek(long filep, short origin, unsigned short offset);
- short LocalFileSize(long filep, long *size);
- short LocalFileResize(long filep, long newsize);
-
-